package com.xbongbong.paas.enums;

import com.xbongbong.saas.enums.XbbRefTypeEnum;
import com.xbongbong.saas.enums.base.CommunicateBaseEnum;
import com.xbongbong.saas.enums.business.AssembleEnum;
import com.xbongbong.saas.enums.business.BomBillEnum;
import com.xbongbong.saas.enums.business.ContactEnum;
import com.xbongbong.saas.enums.business.ContractEnum;
import com.xbongbong.saas.enums.business.CustomerManagementEnum;
import com.xbongbong.saas.enums.business.InstockEnum;
import com.xbongbong.saas.enums.business.InventoryEnum;
import com.xbongbong.saas.enums.business.InvoiceEnum;
import com.xbongbong.saas.enums.business.OriStockEnum;
import com.xbongbong.saas.enums.business.OutstockEnum;
import com.xbongbong.saas.enums.business.PayPlanEnum;
import com.xbongbong.saas.enums.business.PaySheetEnum;
import com.xbongbong.saas.enums.business.PaymentEnum;
import com.xbongbong.saas.enums.business.PaymentSheetEnum;
import com.xbongbong.saas.enums.business.ProductEnum;
import com.xbongbong.saas.enums.business.ProductionOrderEnum;
import com.xbongbong.saas.enums.business.PurchaseEnum;
import com.xbongbong.saas.enums.business.PurchaseInvoiceEnum;
import com.xbongbong.saas.enums.business.QuotationEnum;
import com.xbongbong.saas.enums.business.RefundEnum;
import com.xbongbong.saas.enums.business.SalesOpportunityEnum;
import com.xbongbong.saas.enums.business.SupplierContactEnum;
import com.xbongbong.saas.enums.business.SupplierEnum;
import com.xbongbong.saas.enums.business.TransferEnum;
import lombok.Getter;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;

/**
 *
 */
@Getter
public enum ImportNeedAttrsEnum {
    CUSTOMER(XbbRefTypeEnum.CUSTOMER_MANAGEMENT.getCode(), Arrays.asList(CustomerManagementEnum.CREATOR.getAttr())),
    CONTACT(XbbRefTypeEnum.CONTACT.getCode(), Arrays.asList(ContactEnum.CUSTOMER_NAME.getAttr())),
    CONTRACT(XbbRefTypeEnum.CONTRACT.getCode(), Arrays.asList(ContractEnum.AMOUNT.getAttr(), ContractEnum.PRODUCT.getAttr())),
    SALES_OPPORTUNITY(XbbRefTypeEnum.SALES_OPPORTUNITY.getCode(), Arrays.asList(SalesOpportunityEnum.ESTIMATE_AMOUNT.getAttr(), SalesOpportunityEnum.PRODUCTS.getAttr())),
    CUSTOMER_COMMUNICATE(XbbRefTypeEnum.CUSTOMER_COMMUNICATE.getCode(), Arrays.asList(CommunicateBaseEnum.COMMUNICATE_TIME.getAttr())),
    SUPPLIER_COMMUNICATE(XbbRefTypeEnum.SUPPLIER_COMMUNICATE.getCode(), Arrays.asList(CommunicateBaseEnum.COMMUNICATE_TIME.getAttr())),
    REFUND(XbbRefTypeEnum.REFUND.getCode(), Arrays.asList(RefundEnum.PRODUCTS.getAttr())),
    QUOTATION(XbbRefTypeEnum.QUOTATION.getCode(), Arrays.asList(QuotationEnum.PRODUCT.getAttr())),
    // 资金业务，因为涉及金额计算所需字段过多，所以这边系统字段都需要导入
    PAYMENT(XbbRefTypeEnum.PAYMENT.getCode(), PaymentEnum.getAttrs()),
    PAY_PLAN(XbbRefTypeEnum.PAY_PLAN.getCode(), PayPlanEnum.getAttrs()),
    PAYMENT_SHEET(XbbRefTypeEnum.PAYMENT_SHEET.getCode(), PaymentSheetEnum.getAttrs()),
    PAY_SHEET(XbbRefTypeEnum.PAY_SHEET.getCode(), PaySheetEnum.getAttrs()),
    PURCHASE_INVOICE(XbbRefTypeEnum.PURCHASE_INVOICE.getCode(), PurchaseInvoiceEnum.getAttrs()),
    INVOICE(XbbRefTypeEnum.INVOICE.getCode(), InvoiceEnum.getAttrs()),

    PURCHASE(XbbRefTypeEnum.PURCHASE.getCode(), Arrays.asList(PurchaseEnum.SUPPLIER_ID.getAttr(), PurchaseEnum.PRODUCT.getAttr())),
    SUPPLIER_CONTACT(XbbRefTypeEnum.SUPPLIER_CONTACT.getCode(), Arrays.asList(SupplierContactEnum.SUPPLIER_ID.getAttr(), SupplierContactEnum.NAME.getAttr())),
    SUPPLIER(XbbRefTypeEnum.SUPPLIER.getCode(), Arrays.asList(SupplierEnum.PRODUCT_LIST.getAttr())),
    ASSEMBLE(XbbRefTypeEnum.ASSEMBLE.getCode(), Arrays.asList(AssembleEnum.OUT_WAREHOUSE_ID.getAttr(), AssembleEnum.INTO_WAREHOUSE_ID.getAttr(), AssembleEnum.OUT_PRODUCTS.getAttr(), AssembleEnum.IN_PRODUCTS.getAttr())),
    INVENTORY(XbbRefTypeEnum.INVENTORY.getCode(), Arrays.asList(InventoryEnum.WAREHOUSE_ID.getAttr(), InventoryEnum.PRODUCT.getAttr())),
    TRANSFER(XbbRefTypeEnum.TRANSFER.getCode(), Arrays.asList(TransferEnum.OUT_WAREHOUSE_ID.getAttr(), TransferEnum.INTO_WAREHOUSE_ID.getAttr(), TransferEnum.PRODUCTS.getAttr())),
    PURCHASE_INSTOCK(XbbRefTypeEnum.PURCHASE_INSTOCK.getCode(), Arrays.asList(InstockEnum.TIME.getAttr(), InstockEnum.WAREHOUSE_ID.getAttr(), InstockEnum.REF_ID.getAttr(), InstockEnum.PRODUCT.getAttr())),
    REFUND_INSTOCK(XbbRefTypeEnum.REFUND_INSTOCK.getCode(), Arrays.asList(InstockEnum.TIME.getAttr(), InstockEnum.WAREHOUSE_ID.getAttr(), InstockEnum.REF_ID.getAttr(), InstockEnum.PRODUCT.getAttr())),
    OTHER_INSTOCK(XbbRefTypeEnum.OTHER_INSTOCK.getCode(), Arrays.asList(InstockEnum.TIME.getAttr(), InstockEnum.WAREHOUSE_ID.getAttr(), InstockEnum.REF_ID.getAttr(), InstockEnum.PRODUCT.getAttr())),
    PRODUCTION_INSTOCK(XbbRefTypeEnum.PRODUCTION_INSTOCK.getCode(), Arrays.asList(InstockEnum.TIME.getAttr(), InstockEnum.WAREHOUSE_ID.getAttr(), InstockEnum.REF_ID.getAttr(), InstockEnum.PRODUCT.getAttr())),
    RETURNED_MATERIEL_INSTOCK(XbbRefTypeEnum.RETURNED_MATERIEL_INSTOCK.getCode(), Arrays.asList(InstockEnum.TIME.getAttr(), InstockEnum.WAREHOUSE_ID.getAttr(), InstockEnum.REF_ID.getAttr(), InstockEnum.PRODUCT.getAttr())),
    OUTSTOCK(XbbRefTypeEnum.OUTSTOCK.getCode(), Arrays.asList(OutstockEnum.TIME.getAttr(), OutstockEnum.WAREHOUSE_ID.getAttr(), OutstockEnum.REF_ID.getAttr(), OutstockEnum.PRODUCT.getAttr())),
    CONTRACT_OUTSTOCK(XbbRefTypeEnum.CONTRACT_OUTSTOCK.getCode(), Arrays.asList(OutstockEnum.TIME.getAttr(), OutstockEnum.WAREHOUSE_ID.getAttr(), OutstockEnum.REF_ID.getAttr(), OutstockEnum.PRODUCT.getAttr())),
    RETURNED_PURCHASE_OUTSTOCK(XbbRefTypeEnum.RETURNED_PURCHASE_OUTSTOCK.getCode(), Arrays.asList(OutstockEnum.TIME.getAttr(), OutstockEnum.WAREHOUSE_ID.getAttr(), OutstockEnum.REF_ID.getAttr(), OutstockEnum.PRODUCT.getAttr())),
    OTHER_OUTSTOCK(XbbRefTypeEnum.OTHER_OUTSTOCK.getCode(), Arrays.asList(OutstockEnum.TIME.getAttr(), OutstockEnum.WAREHOUSE_ID.getAttr(), OutstockEnum.REF_ID.getAttr(), OutstockEnum.PRODUCT.getAttr())),
    PRODUCTION_MATERIEL_OUTSTOCK(XbbRefTypeEnum.PRODUCTION_MATERIEL_OUTSTOCK.getCode(), Arrays.asList(OutstockEnum.TIME.getAttr(), OutstockEnum.WAREHOUSE_ID.getAttr(), OutstockEnum.REF_ID.getAttr(), OutstockEnum.PRODUCT.getAttr())),
    WORK_ORDER_OUTSTOCK(XbbRefTypeEnum.WORK_ORDER_OUTSTOCK.getCode(), Arrays.asList(OutstockEnum.TIME.getAttr(), OutstockEnum.WAREHOUSE_ID.getAttr(), OutstockEnum.REF_ID.getAttr(), OutstockEnum.PRODUCT.getAttr())),
    BOM_BILL(XbbRefTypeEnum.BOM_BILL.getCode(), Arrays.asList(BomBillEnum.VERSION.getAttr(), BomBillEnum.PRODUCT.getAttr(), BomBillEnum.MATERIEL.getAttr())),
    PRODUCTION_ORDER(XbbRefTypeEnum.PRODUCTION_ORDER.getCode(), Arrays.asList(ProductionOrderEnum.BOM_ID.getAttr(), ProductionOrderEnum.BOM_VERSION.getAttr(), ProductionOrderEnum.OUT_WAREHOUSE_ID.getAttr(), ProductionOrderEnum.INTO_WAREHOUSE_ID.getAttr(), ProductionOrderEnum.PRODUCT.getAttr())),
    PRODUCT(XbbRefTypeEnum.PRODUCT.getCode(), Arrays.asList(ProductEnum.UNIT.getAttr(), ProductEnum.EXPIRATION_ALERT_DAYS.getAttr(), ProductEnum.SHELF_LIFE_DAYS.getAttr(), ProductEnum.SPECIFICATION.getAttr(), ProductEnum.WAREHOUSE.getAttr(), ProductEnum.ENABLE_BATCH_SHELF_LIFE.getAttr(), ProductEnum.PRICE.getAttr())),
    ORI_STOCK(XbbRefTypeEnum.ORI_STOCK.getCode(), Arrays.asList(OriStockEnum.WAREHOUSE.getAttr())),
    ;

    private Integer businessType;
    private List<String> attrs;

    ImportNeedAttrsEnum(Integer businessType, List<String> attrs) {
        this.businessType = businessType;
        this.attrs = attrs;
    }

    public static List<String> getAttrs(Integer businessType) {
        for (ImportNeedAttrsEnum importNeedAttrsEnum : values()) {
            if (Objects.equals(importNeedAttrsEnum.getBusinessType(), businessType)) {
                return importNeedAttrsEnum.getAttrs();
            }
        }
        return new ArrayList<>();
    }
}
